FROM golang:1.9.4-stretch
#FROM golang:1.9.3-alpine3.6

RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
    && apt update \
    && apt upgrade -y

# add china aliyun repo  新增了 alpine 3.6 的阿里源
# RUN cp   /etc/apk/repositories /etc/apk/repositories.back && \
#     echo "https://mirrors.aliyun.com/alpine/v3.6/main/" >  /etc/apk/repositories && \
#     echo "https://mirrors.aliyun.com/alpine/v3.6/community/" >> /etc/apk/repositories

# RUN apk add --update bash git make gcc g++
RUN apt install -y bash git make gcc g++ calibre
RUN mkdir -p /go/src/github.com/lifei6671
WORKDIR /go/src/github.com/lifei6671

RUN git clone https://github.com/lifei6671/mindoc.git
# RUN wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | python -c "import sys; main=lambda x,y:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main('~/calibre-bin', True)"


# ADD . /go/src/github.com/lifei6671/mindoc

WORKDIR /go/src/github.com/lifei6671/mindoc

RUN chmod +x start.sh

RUN go get -d ./... && \
    CGO_ENABLE=1 go build -v -o mindoc_linux_amd64 -ldflags="-w -X main.VERSION=$TAG -X 'main.BUILD_TIME=`date`' -X 'main.GO_VERSION=`go version`'" && \
        rm -rf commands controllers models modules routers tasks vendor docs search data utils graphics .git Godeps uploads/* .gitignore .travis.yml Dockerfile gide.yaml LICENSE main.go README.md conf/enumerate.go conf/mail.go install.lock


CMD ["./start.sh"]

#docker build -t wolferhua/mindoc .